package com.retail.lottery.colalottery.controller;


import com.retail.lottery.colalottery.annotation.DecryptResponse;
import com.retail.lottery.colalottery.annotation.EncryptResponse;
import com.retail.lottery.colalottery.enums.CommonEnum;
import com.retail.lottery.colalottery.service.ApiForwardService;
import com.retail.lottery.colalottery.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.HandlerMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api-forward")
@Slf4j
public class ApiForwardController {
    ;
    @Resource
    private ApiForwardService apiForwardService;

    /**
     * 转发接口（暂未使用）
     *
     * @param request
     * @return
     */
//    @EncryptResponse
//    //@DecryptResponse
//    @RequestMapping("/**")
//    public ResultVO<?> forwardRequest(
//            HttpMethod method,
//            HttpServletRequest request,
//            @RequestBody(required = false) String body,
//            @RequestParam MultiValueMap<String, ?> params,
//            @RequestHeader HttpHeaders headers) {
//        // 抽奖所有接口转发流程(暂时不做了，可乐所有接口交给前端处理)
//        if (method == HttpMethod.POST && StringUtils.isEmpty(body)) {
//        return ResultVO.error(CommonEnum.BODY_NOT_MATCH);
//         }
//
//        // 获取实际请求路径(去掉前缀)
//        String path = (String) request.getAttribute(
//                HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
//        // 调用转发服务
//        return apiForwardService.forward(path.replaceFirst("/api-forward", ""),
//                method, params, headers, body);
//        return null;
//    }


}
